<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.io.*,java.util.*" %>
<html>
<head>
    <title>Web文件操作</title>
</head>
<body>
<%
    String filePath = this.getServletContext().getRealPath("/uploads/" + request.getParameter("fname"));
    File file = new File(filePath);
    Scanner scanner = new Scanner(file); // 文件读取
    scanner.useDelimiter("\n");
%>
    <h2>当前访问路径：<%=filePath%></h2>
<%
    while (scanner.hasNext()) {
        String str = scanner.next();
%>
        <%=str%><br/>
<%
    }
%>
</body>
</html>
